/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package numberporting.server;

import java.io.IOException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.ws.security.WSPasswordCallback;

/**
 *
 * @author hahnepeter
 */
public class ServerPasswordCallback implements CallbackHandler{

    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

        if (pc.getIdentifer().equals("joe")) {
           if (!pc.getPassword().equals("password")) {
                throw new SecurityException("wrong username/password");
           }
        } else {
            throw new SecurityException("wrong username/password");
        }
    }

}
